package com.winterwar.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.winterwar.base.RegisteredEvent;
import com.winterwar.dao.RegisteredEventDAO;
import com.winterwar.service.RegisteredEventManager;

public class RegisteredEventManagerImpl implements RegisteredEventManager {

	public RegisteredEvent get(String regEventID) {
		RegisteredEvent event = dao.get(Integer.valueOf(regEventID));
		if(event == null){
			log.warn("Registered Event with ID " + regEventID + " does not exist in the database.");
		}
		return event;
	}

	public List getAll() {
		return dao.getAll();
	}

	public void remove(String regEventID) {
		dao.remove(Integer.valueOf(regEventID));
	}

	public RegisteredEvent save(RegisteredEvent event) {
		dao.save(event);
		return event;
	}

	public void setDAO(RegisteredEventDAO dao) {
		this.dao = dao;
	}
	
	public List getByRegistration(String registrationID) {
		return dao.getByRegistration(Integer.valueOf(registrationID));
	}

	private RegisteredEventDAO dao;
	private static Log log = LogFactory.getLog(RegisteredEventManager.class);
}
